<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<script>
    function Phone(brand,price){
        this.brand = brand;
        this.price = price;
    }

    //添加方法
    Phone.prototype.call = function (){
        console.log("I can call phone");
    }
    let huawei = new Phone('huawei',5999);
    huawei.call();
    console.log(huawei);

    //class ES6写法
    class Student{
        //构造方法,名字不能更改
        constructor(name,age) {
            this.name = name;
            this.age = age;
        }
        //方法必须使用该语法
        call(){
            console.log("I can walk");
        }
    }
    let onePlus = new Student("1+",111);
    console.log(onePlus);

</script>

</body>
</html>